﻿// Write a program to calculate n! for each n in the range [1..100]. 
// Hint: Implement first a method that multiplies a number represented as array of digits by given integer number. 

using System;
using System.Collections.Generic;

class CalcBigNumberFactorial
{
    static void Main()
    {
        int[] arr1 = { 1, 5 };
        int[] arr2 = { 1, 2, 5 };

        int[] arr3 = MultiplyBigNumber(arr1, arr2);

        Console.WriteLine(String.Join("", arr3));
    }

    private static int[] MultiplyBigNumber(int[] numberArray1, int[] numberArray2)
    {
        int[] result = new int[numberArray1.Length + numberArray2.Length];
        int remainder = 0;
        for (int i = 0; i < numberArray2.Length; i++)
        {
            if (numberArray2[i] == 0)
            {
                continue;
            }

            for (int j = 0; j < numberArray1.Length; j++)
            {
                int multiplication = numberArray2[i] * numberArray1[j];
                result[i + j] += multiplication / 10;
                remainder = multiplication % 10;
                if (remainder != 0)
                {
                    result[i + j + 1] += remainder;
                    //result[i + j] %= 10;
                }
                //result[i + j + 1] += multiplication / 10;
            }
        }

        return result;
    }
}